package poker;

import javax.swing.*;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


public class CardGui extends JButton {
	boolean Marked = false;
	final ImageIcon icon;
	final ImageIcon back;
	private boolean PossibleOfChange=false; 
	private static final long serialVersionUID = 1L;
	
	boolean getPossibleOfChange(){
		return PossibleOfChange;
	}
	
	void setPossibleOfChange(boolean PossibleOfChange){
		this.PossibleOfChange=PossibleOfChange;
	}
	
	boolean getMarked(){
		return Marked;
	}
	
	public CardGui(int type, int value)	{
	
	final String nameoffile = "/Foty/("+(type+1)+","+(value+2)+").png";
		icon = new ImageIcon(TableGui.class.getResource("/Foty/("+(type+1)+","+(value+2)+").png"));
		back = new ImageIcon(TableGui.class.getResource("/Foty/("+(type+1)+","+(value+2)+") - Kopia.png"));
		setIcon(new ImageIcon(TableGui.class.getResource(nameoffile)));
		setIcon(icon);
		setBorder(null);
		setBorderPainted(false);
		setOpaque(true);
		addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (PossibleOfChange){
					if (getIcon() == back)	{
						Marked=false;
						setIcon(icon);	
						//setEnabled(false);
					}
					else {
						Marked=true;
						setIcon(back);
						setOpaque(true);
					}
				}
					
			}
			});
	}
	public boolean hideornot(){
		if (getIcon() == back)	{
			return true;	
		}
		return false;
	}
	public void disable(){
		
			setEnabled(false);
	}
}
